export default {
    namespaced: true,
    state() {
        return {
            TagView: [],
            collapse: false
        }
    },
    mutations: {
        AddTag(state, data) {
            if (state.TagView.some(v => v.path === data.path)) return
            state.TagView.push(
                Object.assign({}, data, {
                    title: data.meta.title || 'no-name'
                })
            )
        },
        DelTag(state, data) {
            const index = state.TagView.indexOf(data)
            index > -1 && state.TagView.splice(index, 1)
        },
        DelTagAll(state, data) {
            state.TagView = []
        },
        IsCollapse(state, data) {
            state.collapse = data
        },
    },
    actions: {
        AddTagView(context, data) {
            context.commit('AddTag', data)
        },
        DelTagView(context, data) {
            context.commit('DelTag', data)
        },
        DelTagViewAll(context, data) {
            context.commit('DelTagAll', data)
        },
        SetCollapse(context, data) {
            context.commit('IsCollapse', data)
        },
    },
    getters: {

    }
}